package dto

import (
	"time"
	"vrcm/src/vrcm/app/admin/models/live_schedule"
	"vrcm/src/vrcm/common/dto"
	common "vrcm/src/vrcm/common/models"
)

type ChannelBasicGetPageReq struct {
	dto.Pagination `search:"-"`
	TenantId       string `json:"tenant_id" search:"-"`
	ChannelId      int    `json:"channel_id" search:"-"`
	ChannelState   int    `json:"channel_state"  search:"type:exact;column:channel_state;table:channel_basic"`
	IsDelete       int    `json:"is_delete"  search:"-"`
}

type ChannelBasicOrder struct {
	Id           string `form:"idOrder"  search:"type:order;column:id;table:channel_basic"`
	ChannelName  string `form:"channel_nameOrder"  search:"type:order;column:channel_name;table:channel_basic"`
	ChannelDesc  string `form:"channel_descOrder"  search:"type:order;column:channel_desc;table:channel_basic"`
	ChannelState string `form:"channel_stateOrder"  search:"type:order;column:channel_state;table:channel_basic"`
	RunState     string `form:"run_stateOrder"  search:"type:order;column:run_state;table:channel_basic"`
	StartTime    string `form:"start_timeOrder"  search:"type:order;column:start_time;table:channel_basic"`
	EndTime      string `form:"end_timeOrder"  search:"type:order;column:end_time;table:channel_basic"`
	CreateTime   string `form:"create_timeOrder"  search:"type:order;column:create_time;table:channel_basic"`
	UpdateTime   string `form:"update_timeOrder"  search:"type:order;column:update_time;table:channel_basic"`
	CreateBy     string `form:"createByOrder"  search:"type:order;column:create_by;table:channel_basic"`
	UpdateBy     string `form:"updateByOrder"  search:"type:order;column:update_by;table:channel_basic"`
}

func (m *ChannelBasicGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type ChannelBasicInsertReq struct {
	Id          int    `uri:"id" comment:""` //
	TenantId    string `json:"tenant_id" comment:"租户id" validate:"required"`
	ChannelName string `json:"channel_name" comment:"通道名称" validate:"required"`
	ChannelDesc string `json:"channel_desc" comment:"通道描述"`
	//ChannelState int64  `json:"channel_state" comment:"通道状态 1 启用 2停用 3 异常" validate:"gt=0"`
	RunState  int64 `json:"run_state" comment:"运行模式 1手动启用 2预约启用"`
	StartTime int64 `json:"start_time" comment:"启用时间"`
	EndTime   int64 `json:"end_time" comment:"停用时间"`
	common.ControlBy
}

func (s *ChannelBasicInsertReq) Generate(model *live_schedule.ChannelBasic) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	now := time.Now().Unix()
	model.TenantId = s.TenantId
	model.ChannelName = s.ChannelName
	model.ChannelDesc = s.ChannelDesc
	model.ChannelState = 2
	model.RunState = s.RunState
	model.StartTime = s.StartTime
	model.EndTime = s.EndTime
	model.CreateTime = now
	model.UpdateTime = now
	model.IsSchedule = 2
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
	model.IsDelete = 2
	model.IsTime = 2
}

func (s *ChannelBasicInsertReq) GetId() interface{} {
	return s.Id
}

type ChannelBasicUpdateReq struct {
	Id          int    `uri:"id" comment:""` //
	TenantId    string `json:"tenant_id" comment:"租户id" validate:"required"`
	ChannelName string `json:"channel_name" comment:"通道名称" validate:"required"`
	ChannelDesc string `json:"channel_desc" comment:"通道描述"`
	//ChannelState int64  `json:"channel_state" comment:"通道状态 1 启用 2停用 3 异常" validate:"gt=0"`
	RunState  int64  `json:"run_state" comment:"运行模式 1手动启用 2预约启用"`
	StartTime int64  `json:"start_time" comment:"启用时间"`
	EndTime   int64  `json:"end_time" comment:"停用时间"`
	BasicInfo string `json:"basic_info" comment:"基础信息"`
	common.ControlBy
}

func (s *ChannelBasicUpdateReq) Generate(model *live_schedule.ChannelBasic) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.TenantId = s.TenantId
	model.ChannelName = s.ChannelName
	model.ChannelDesc = s.ChannelDesc
	model.RunState = s.RunState
	//model.StartTime = s.StartTime
	//model.EndTime = s.EndTime
	model.BasicInfo = s.BasicInfo
	model.UpdateTime = time.Now().Unix()
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

func (s *ChannelBasicUpdateReq) GetId() interface{} {
	return s.Id
}

// ChannelBasicGetReq 功能获取请求参数
type ChannelBasicGetReq struct {
	Id int `uri:"id"`
}

func (s *ChannelBasicGetReq) GetId() interface{} {
	return s.Id
}

// ChannelBasicDeleteReq 功能删除请求参数
type ChannelBasicDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *ChannelBasicDeleteReq) GetId() interface{} {
	return s.Ids
}

type GetChannelsBySourceReq struct {
	SourceId int    `json:"source_id" comment:"信源id" validate:"required"`
	TenantId string `json:"tenant_id" comment:"租户id" validate:"required"`
}
